//接口契约，就是为这些类型命名和代码块进行约束
//是一些方法特征的集合
interface A{
    [index:number]:number
}

let a:A = [1,2,3]
let a1:A = {
    1:1,
    2:2,
    3:3
}

interface B{
    (): void
    (username:string,age:number):string
}

let b1:() => void = () => {}
let b2:(username:string,age:number) => string = (username:string,age:number) => {return  ''}

interface C{
    readonly username:string
    age?: number
}

let c:C = {
    username:'123',
    age:1
}

//只读
//c.username = '123'

interface D{
    username:string
}

//3：接口继承合并
interface E extends D{
    age:number
}

let e:E = {
    username:'123',
    age:1
}

//4:type具备映射类型
type F = {
    [P in 'username' | 'age']:string
}

let f1:F = {
    username:'123',
    age:'123'
}